#include <stdio.h>

int main() 
{
    int X = 0;
    int N = 0;
    X >= 1 && X <= 7;
    N >= 1 && N <= 1000;

    scanf("%d %d",&X,&N);
    int x = X + N;
    x = (x-1) % 7 + 1;//先-1除完再+1避免周天出现余数变成0的情况
    printf("%d",x);

    return 0;
}